<?php
/**
 * Created by PhpStorm.
 * User: osxfal
 * Date: 2019/2/23
 * Time: 下午6:37
 */


namespace app\index\controller;
use think\Controller;

/* 用户管理*/
class History extends Controller{

    //判断用户是否登录
    /*public function __construct()
    {
        parent::__construct();
        if(empty(session('user')))
        {
            $this->error('对不起,您还没有登录!请先登录!','index/login');


        }

    }*/

    /* app端客户浏览记录 */
    public function person_view_history(){


        $uid = input('get.uid'); //用户id 通过连表查询 获取 用户流量 app的记录
        if(empty($uid)){
           
            $ret['result'] = 2;
            $ret['tips'] = 'uid丢失，非法操作！';
            exit(json_encode($ret,320));
        }

        $where = [];

        $where['a.uid'] = trim($uid);

        $field = 'a.uid,a.date,b.title,b.title2,
                    b.money,b.maxmoney,b.jiage,b.minfeilv,b.yunjiage,b.maxdate,b.zongrenshu,b.thumb'; //初始化  字段

        $join = [
            ['go_shoplist b','a.shopid=b.id','LEFT'],
        ];

        $res = db('shop_dj')
                ->alias('a')
                ->field($field)
                ->join($join)
                ->where($where)
                ->limit('0,20')
                ->order('a.id desc')
                ->select();

        // $total = db('member')->field('COUNT(uid) as t')->where(['uid'=>$uid])->find();
        
        //拼接logo 地址
        foreach($res as &$v){
            $v['thumb'] = 'http://wyq.weikj.net:86/uploads/' . $v['thumb'];
        }

        $ret = [];
        if(!empty($res)){
            $ret['rows'] = $res;
            // $ret['total'] = $total['t'];
            $ret['result'] = 1;
            $ret['tips'] = '查询成功！';


        }
        elseif(empty($res)){
            $ret['rows'] = [];
            $ret['total'] = 0;
            $ret['result'] = 1;
            $ret['tips'] = '查询成功！并没有符合条件的数据！';
        }
        else{
            $ret['rows'] = [];
            $ret['total'] = 0;
            $ret['result'] = 2;
            $ret['tips'] = '查询失败，请稍后再试~~';

        }



        $ret = json_encode($ret,JSON_UNESCAPED_UNICODE);
        exit($ret);


    }//func  userlist

}